import {
    ajaxPost,
    showToast
} from '../../utils/util'
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        hidden: {
            type: Boolean,
            value: false
        },
        type: {
            type: Number,
            value: 1
        },
        workid: {
            type: String,
            value: ''
        },
        uid: {
            type: String,
            value: ''
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        reportitem: ['广告', '色情', '违法-政治敏感信息', '职位造假', '索取隐私', '含有歧视信息', '猎头骚扰', '传销', '以培训名义招生'],
        hidden: false,
        type: 1,
        uid: '',
        workid: '',
    },

    /**
     * 组件的方法列表
     */
    methods: {
        showReport() {
            this.setData({
                hidden: false
            })
        },
        tapItem(e) {
            console.log(this.data.uid);

            let data = {
                token: wx.getStorageSync('token'),
                type: this.data.type,
                reason: this.data.reportitem[e.currentTarget.dataset.item],
                content: '',
                complaint_uid: this.data.uid,

            }
            if (this.data.type == 2) {
                data.position_id = this.data.workid
            }
            ajaxPost('/authuser/complaint', data, res => {
                if (res.code == 0) {
                    showToast('text', '投诉成功');
                    this.setData({
                        hidden: false
                    })
                }
            })

        }
    }
})